﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Libs.Content;
using System.Data;
using System.Configuration;

public partial class Pages_Media : System.Web.UI.Page
{
    private Libs.Content.NewsMedia media = new NewsMedia();
    private DataTable l_Media;
    private int NewsID = 0;
    protected string Media_Path = ConfigurationManager.AppSettings["MEDIA"].ToString();
    protected void Page_Load(object sender, EventArgs e)
    {
        List<NewsWeb> listVideo;
        NewsWeb _NewsWeb = new NewsWeb();
        //if(!string.IsNullOrEmpty(Request.QueryString["nid"])) 
        //    int.TryParse(Request.QueryString["nid"], out NewsID);

        NewsID = AppUtils.Request("nid");
        if (NewsID == 0)
        {
            List<NewsWeb> list;
            list = _NewsWeb.GetList(52, 0, 1);
            _NewsWeb = list[0];
            lblTitle.Text = _NewsWeb.Title;
            lblTime.Text = _NewsWeb.PublishedTime.ToString("HH'h'mm '|' dd/MM/yyyy");
            NewsID = _NewsWeb.NewsID;
        }
        else
        {
            var _News = new News();
            _News = _News.Get(NewsID);
            lblTitle.Text = _News.Title;
            lblTime.Text = _News.PublishedTime.ToString("HH'h'mm '|' dd/MM/yyyy");
        }

        l_Media = media.GetList(NewsID);

        rptMedia.DataSource = l_Media;
        rptMedia.DataBind();


        //listAudio = _NewsWeb.GetList(53, 0, 1);
        //rptAudio.DataSource = listAudio;
        //rptAudio.DataBind();

        listVideo = _NewsWeb.GetList(47, 0, 5);
        rptVideo.DataSource = listVideo;
        rptVideo.DataBind();

        rptImage.DataSource = _NewsWeb.GetList(52, 0, 5); ;
        rptImage.DataBind();
    }
}